home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / tstentry.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  3KB  |  91 lines

  1. Program tstentry;
  2.  
  3. { Example for the nwFile unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  4.  
  5. { Tests the following nwFile calls:
  6.  
  7.   AllocPermanentDirHandle
  8.   CreateDirectory
  9.   DeallocateDirHandle
  10.   RenameDirectory
  11.   ScanDirRestrictions
  12.   SetDirectoryHandle
  13.   SetDirRestriction
  14.  
  15. }
  16. uses nwMisc,nwFile;
  17.  
  18. Var DirHandle:Byte;
  19.     NumberOfEntries:Byte;
  20.     RestrInfo:TdirRestrList;
  21.     t,EffRights:Byte;
  22.  
  23. begin
  24.  
  25.  
  26. AllocPermanentDirHandle(7,0,'SYS:',DirHandle,EffRights);
  27.  
  28. IF NOT CreateDirectory(DirHandle,'NWTP',$FF)
  29.  then writeln('Error using CreateDirectory, err# ',nwFile.result);
  30.  
  31. SetDirectoryHandle(DirHandle,'NWTP',DirHandle);
  32.  
  33. IF NOT SetDirRestriction(DirHandle,4096) { 4096 blocks = 16 Mb }
  34.  then writeln('Error using SetDirRestriction, err# ',nwFile.result);
  35.  
  36. IF NOT ScanDirRestrictions(DirHandle,NumberOfEntries,RestrInfo)
  37.  then writeln('Error calling ScanDirRestrictions:',nwFile.result);
  38. writeln(NumberOfEntries);
  39. For t:=1 to NumberOfEntries
  40.  do begin
  41.     writeln;
  42.     writeln('Level      :',RestrInfo[t].level);
  43.     writeln('MaxBlocks  :',HexStr(RestrInfo[t].MaxBlocks,8));
  44.     writeln('AvailBlocks:',HexStr(RestrInfo[t].AvailableBlocks,8));
  45.     end;
  46. writeln('------');
  47.  
  48. IF NOT CreateDirectory(DirHandle,'TEST',$FF)
  49.  then writeln('Error using CreateDirectory, err# ',nwFile.result);
  50.  
  51. IF NOT RenameDirectory(DirHandle,'TEST','TESTDIR')
  52.  then writeln('Error using RenameDirectory, err# ',nwFile.result);
  53.  
  54.  
  55. IF NOT SetDirectoryHandle(DirHandle,'TESTDIR',DirHandle)
  56.   then writeln('Error using SetDirectoryHandle, err# ',nwFile.result)
  57.   else writeln('SetDirHandle: ok');
  58.  
  59. IF NOT SetDirRestriction(DirHandle,8192)
  60.  then writeln('Error using SetDirRestriction, err# ',nwFile.result);
  61.  
  62. IF NOT ScanDirRestrictions(DirHandle,NumberOfEntries,RestrInfo)
  63.  then writeln('Error calling ScanDirRestrictions:',nwFile.result);
  64. writeln(NumberOfEntries);
  65. For t:=1 to NumberOfEntries
  66.  do begin
  67.     writeln;
  68.     writeln('Level      :',RestrInfo[t].level);
  69.     writeln('MaxBlocks  :',HexStr(RestrInfo[t].MaxBlocks,8));
  70.     writeln('AvailBlocks:',HexStr(RestrInfo[t].AvailableBlocks,8));
  71.     end;
  72.  
  73. writeln('<Return> to continue...........');
  74. readln;
  75.  
  76. SetDirRestriction(DirHandle,0);
  77.  
  78. SetDirectoryHandle(0,'SYS:NWTP',DirHandle);
  79. IF Not DeleteDirectory(DirHandle,'TESTDIR')
  80.  then writeln('Error using DeleteDirectory, err#', nwFile.result);
  81.  
  82. {SetDirRestriction(DirHandle,0);}
  83.  
  84. SetDirectoryHandle(0,'SYS:',DirHandle);
  85. IF Not DeleteDirectory(DirHandle,'NWTP')
  86.  then writeln('Error using DeleteDirectory, err#', nwFile.result);
  87.  
  88.  
  89. DeallocateDirHandle(DirHandle);
  90.  
  91. end.